'use strict'

class goods{
    constructor(mdb){
        this.db=mdb
        this.tablename='news'
    }
    model(){
        return this.db.model(this.tablename)
    }

    makeId () {
        return `u_${Date.now().toString(16)}${parseInt(Math.random()*10000) + 11111}`
    }

    async select (userid,friendid) {
        let ulist = await this.model().limit(20).where({userid,friendid}).select()
        return ulist.rows
    }

    async insert(data){
        data.newsid=this.makeId()
        await this.model().insert(data)
        return data.newsid
    }
}
module.exports=goods